package cn.luoyifan.hrm.service.impl;

import cn.luoyifan.hrm.constants.BaseConstants;
import cn.luoyifan.hrm.domain.Meal;
import cn.luoyifan.hrm.mapper.MealMapper;
import cn.luoyifan.hrm.service.IMealService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 套餐表 服务实现类
 * </p>
 *
 * @author whale.luoyifan
 * @since 2021-11-22
 */
@Service
public class MealServiceImpl extends ServiceImpl<MealMapper, Meal> implements IMealService {

    @Autowired
    private MealMapper mealMapper;

    @Override
    public void saveRelationWithLogin(Long meadId, Long loginId) {
        //试用7天
        Date expireTime = DateUtils.addDays(new Date(), 7);


        mealMapper.saveRelationWithLogin(
                meadId, //套餐ID
                loginId,    //机构管理员的Login
                expireTime, //试用结束时间
                BaseConstants.Meal.STATE_UN_PAY);   //状态：未支付

    }
}
